package deng.ejb3.examples.webclient;

import java.io.IOException;

import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import deng.ejb3.examples.simplecase.client.MainHelper;

/**
 * Servlet implementation class EmployeeDalAccessServlet
 */
public class EmployeeDalAccessServlet extends HttpServlet {
	
	private static final long serialVersionUID = 1L;
	private static Logger logger = LoggerFactory.getLogger(EmployeeDalAccessServlet.class);

//	@EJB
//	private EmployeeDalAccessLocal employeeDalAccess;
	
    public EmployeeDalAccessServlet() {
        super();
    }

	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		logger.info("getRequestURI: " + request.getRequestURI());
		

		Context ctx = null;
		try {
			ctx = new InitialContext();
//			EmployeeDalAccessBean employeeDalAccess = (EmployeeDalAccessBean)ctx.lookup("EmployeeDalAccessBean/local");
//			logger.info("employeeDalAccess: " + employeeDalAccess);
		} catch (NamingException e) {
			throw new RuntimeException("Failed on EJB action.", e);
		} finally {
			MainHelper.close(ctx);
		}
	}

	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
	}

}
